package cn.lf.controller;


import cn.lf.dto.order.OrderInfoAddDTO;
import cn.lf.dto.order.OrderInfoSetDTO;
import cn.lf.dto.sys.order.OrderInfoGetRepDTO;
import cn.lf.dto.sys.order.OrderInfoGetReqDTO;
import cn.lf.dto.sys.order.OrderInfoSingleDTO;
import cn.lf.dto.order.OrderStatusSetDTO;
import cn.lf.service.IOrderInfoService;
import cn.lf.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author guoyy
 * @since 2024-04-07
 */
@RestController
@RequestMapping("/order-info")
@Api(tags = "订单信息相关接口")
public class OrderInfoController {

    @Autowired
    private IOrderInfoService orderInfoService;

    @GetMapping("/queryOrderInfoPage")
    @ApiOperation("获取订单信息列表 分页")
    public ResponseModel<IPage<OrderInfoGetRepDTO>> queryOrderInfoPage(OrderInfoGetReqDTO params){

        IPage<OrderInfoGetRepDTO> result = orderInfoService.queryOrderInfoPage(params);

        return ResponseModel.buildSuccessResult(result);
    }

    /**
     *
     * @return
     */
    @PostMapping("addOrderInfo")
    @ApiOperation("新增订单信息")
    public ResponseModel addOrderInfo(@RequestBody OrderInfoAddDTO orderInfoAddDTO){

        orderInfoService.addOrderInfo(orderInfoAddDTO);

        return ResponseModel.buildSuccessResult();
    }

    @PostMapping("setOrderStatus")
    @ApiOperation("设置订单状态")
    public ResponseModel setOrderStatus(@RequestBody OrderStatusSetDTO orderStatusSetDTO){

        orderInfoService.setOrderStatus(orderStatusSetDTO);

        return ResponseModel.buildSuccessResult();
    }

    @GetMapping("/getOrderInfoById")
    @ApiOperation("根据id获取订单信息")
    public ResponseModel<OrderInfoSingleDTO> getOrderInfoById(@RequestParam String orderId){

        OrderInfoSingleDTO result = orderInfoService.getOrderInfoById(orderId);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("setOrderInfo")
    @ApiOperation("设置订单信息")
    public ResponseModel setOrderInfo(@RequestBody OrderInfoSetDTO orderInfoSetDTO){

        orderInfoService.setOrderInfo(orderInfoSetDTO);

        return ResponseModel.buildSuccessResult();
    }

    @GetMapping("/delOrderInfoById")
    @ApiOperation("根据id删除订单信息 真删")
    public ResponseModel delOrderInfoById(@RequestParam String orderId){

        orderInfoService.delOrderInfoById(orderId);

        return ResponseModel.buildSuccessResult();
    }

}
